/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sunrise.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author frank
 */
@Entity
@NamedQueries({
        @NamedQuery(name = Location.findByPlaceIdentifier, query = "SELECT l FROM Location l WHERE l.placeIdentifier = :placeIdentifier")
})
public class Location implements Serializable {
    private static final long serialVersionUID = 1L;
    
    public static final String findByPlaceIdentifier = "Location.findByPlaceIdentifier";
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(length=255, nullable=false)
    private String description;

//    @Column(unique=true)
    private String placeIdentifier;
    
    @Column(length=45)
    private String latitude;
    
    @Column(length=45)
    private String longitude;
    
    public Location() {
        this.id = null;
        this.description = "";
        this.placeIdentifier = "";
        this.latitude = "";
        this.longitude = "";
    }
    
    public Location(String description, String placeIdentifier, String latitude, String longitude) {
        this.id = null;
        this.description = description;
        this.placeIdentifier = placeIdentifier;
        this.latitude = latitude;
        this.longitude = longitude;
    }
    
    /*
    @Column(columnDefinition="FLOAT(10,6)", nullable=false)
    private float latitude;
    
    @Column(columnDefinition="FLOAT(10,6)", nullable=false)
    private float longitude;
    */
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPlaceIdentifier() {
        return placeIdentifier;
    }

    public void setPlaceIdentifier(String placeIdentifier) {
        this.placeIdentifier = placeIdentifier;
    }

    /*
    public float getLatitude() {
        return latitude;
    }

    public void setLatitude(float latitude) {
        this.latitude = latitude;
    }

    public float getLongitude() {
        return longitude;
    }

    public void setLongitude(float longitude) {
        this.longitude = longitude;
    }
    */

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Location)) {
            return false;
        }
        Location other = (Location) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sunrise.entity.Location[ id=" + id + " ]";
    }
    
}
